{extend name='main'}

{block name="button"}

{if auth("add_users")}
<!--<button data-modal='{:url("add_users")}' data-title="添加会员" class='layui-btn'>添加会员</button>-->
{/if}

{/block}

{block name="content"}

<div class="think-box-shadow">
    {include file='withdrawal/index_search'}
    <table class="layui-table" lay-filter="tab" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th lay-data="{field:'order_id',width:150}" class='text-left nowrap'>订单号</th>
            <!--<th lay-data="{field:'uid',width:70}" class='text-left nowrap'>用户ID</th>-->
            <th lay-data="{field:'username'}" class='text-left nowrap'>账号</th>
            <th lay-data="{field:'phone'}" class='text-left nowrap'>账号手机</th>
            <th lay-data="{field:'apply_money'}" class='text-left nowrap'>申请金额</th>
            <th lay-data="{field:'service_money'}" class='text-left nowrap'>收服务费</th>
            <th lay-data="{field:'actual_money'}" class='text-left nowrap'>应付金额</th>
            <th lay-data="{field:'status'}" class='text-left nowrap'>状态</th>
            <th lay-data="{field:'bank_name'}" class='text-left nowrap'>Bank_Name</th>
            <th lay-data="{field:'holder_name'}" class='text-left nowrap'>Holder_Name</th>
            <th lay-data="{field:'account_number'}" class='text-left nowrap'>Account_Number</th>
            <th lay-data="{field:'phone_number'}" class='text-left nowrap'>Phone_Number</th>
            <!--<th lay-data="{field:'email'}" class='text-left nowrap'>Email</th>-->
            <!--<th lay-data="{field:'ifsc'}" class='text-left nowrap'>IFSC</th>-->
            <!--<th lay-data="{field:'upi'}" class='text-left nowrap'>UPI</th>-->
            <th lay-data="{field:'df_type'}" class='text-left nowrap'>代付方式</th>
            <th lay-data="{field:'create_time',width:300}" class='text-left nowrap'>申请时间</th>
            <th lay-data="{field:'edit',fixed: 'right'}" class='text-left nowrap'>操作</th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='text-left nowrap'>{$vo.order_id}</td>
            <!--<td class='text-left nowrap'>{$vo.uid}</td>-->
            <td class='text-left nowrap'>{$vo.username}</td>
            <td class='text-left nowrap'>{$vo.phone}</td>
            <td class='text-left nowrap'>{$vo.apply_money}</td>
            <td class='text-left nowrap'>{$vo.service_money}</td>
            <td class='text-left nowrap'>{$vo.actual_money}</td>
            {switch vo.status}
            {case 0}<td class='text-left nowrap'><span class="color-blue">等待处理</span></td>{/case}
            {case 1}<td class='text-left nowrap'><span class="color-green">处理中</span></td>{/case}
            {case 2}<td class='text-left nowrap'><span class="color-red">已拒绝支付</span></td>{/case}
            {case 3}<td class='text-left nowrap'><span class="color-desc">已完成</span></td>{/case}
            {/switch}
            <td class='text-left nowrap'>{$vo.bank_name}</td>
            <td class='text-left nowrap'>{$vo.holder_name}</td>
            <td class='text-left nowrap'>{$vo.account_number}</td>
            <td class='text-left nowrap'>{$vo.phone_number}</td>
            <!--<td class='text-left nowrap'>{$vo.email}</td>-->
            <!--<td class='text-left nowrap'>{$vo.ifsc}</td>-->
            <!--<td class='text-left nowrap'>{$vo.upi}</td>-->
            <td class='text-left nowrap'>{$vo.df_type}</td>
            <td class='text-left nowrap'>{$vo.create_time|format_datetime}</td>
            <td class='text-left nowrap'>
                {if auth("Withdrawal_handle")}
                {if ($vo.status == 0) and auth("Withdrawal_handle")}
                <!--<button type="button" onClick="pass({$vo.id},1)" class="layui-btn layui-btn-xs">WorldWide Pay</button>-->
                <!--<button type="button" onClick="pass({$vo.id},2)" class="layui-btn layui-btn-xs">qeapay</button>-->
                <!--<button type="button" onClick="pass({$vo.id},5)" class="layui-btn layui-btn-xs">Le</button>-->
                <!--<button type="button" onClick="pass({$vo.id},4)" class="layui-btn layui-btn-xs">Qe</button>-->
                <button type="button" onClick="pass({$vo.id},8)" class="layui-btn layui-btn-xs">wowpay2</button>
                <button type="button" onClick="pass({$vo.id},9)" class="layui-btn layui-btn-xs">qeapay2</button>
                <button type="button" onClick="pass({$vo.id},10)" class="layui-btn layui-btn-xs">lexmpay</button>
                <button type="button" onClick="pass({$vo.id},3)" class="layui-btn layui-btn-xs">手动通过</button>
                <button type="button" onClick="refuse({$vo.id})" class="layui-btn layui-btn-danger layui-btn-xs" >拒绝支付</button>
                
                {/if}
                {/if}
                {if ($vo.status == 3)}
                <button type="button" class="layui-btn layui-btn-xs layui-btn-disabled">已完成</button>
                {/if}
                {if ($vo.status == 1)}
                <button type="button" class="layui-btn layui-btn-xs layui-btn-disabled">处理中</button>
                {/if}
                
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>

    <script>
        function pass(id,types){
            var lock = false;
            layer.confirm('确定已完成支付?',{btn:['确定','取消']},function(index){
                if(!lock) {
                    //加锁防止多次回调
                    lock =true;
                    layer.load(2);
                    $.ajax({
                        url: "{:Url('withdrawal_pass')}",
                        type: "post",
                        traditional: true,
                        data: {id:id,type:types},
                        success: function (e) {
                            layer.closeAll('loading');
                            if (e.code === 1){
                                layer.msg(e.msg, {
                                    time: 2000,
                                    end: function () {
                                        location.reload();
                                    }
                                });
                            }else {
                                layer.msg(e.msg, function(){});
                                return false;
                            }
                        },
                    });
                }
            });
        }
    </script>

    <script>
        function refuse(id){
            var lock = false;
            layer.confirm('确定拒绝支付?',{btn:['确定','取消']},function(index){
                if(!lock) {
                    //加锁防止多次回调
                    lock =true;
                    layer.load(2);
                    $.ajax({
                        url: "{:Url('withdrawal_refuse')}",
                        type: "post",
                        traditional: true,
                        data: {id:id},
                        success: function (e) {
                            layer.closeAll('loading');
                            if (e.code === 1){
                                layer.msg(e.msg, {
                                    time: 2000,
                                    end: function () {
                                        location.reload();
                                    }
                                });
                            }else {
                                layer.msg(e.msg, function(){});
                                return false;
                            }
                        },
                    });
                }
            });
        }
    </script>

    <script>
        var table = layui.table;
        //转换静态表格
        var limit = Number('{$Think.get.limit}');
        if(limit==0) limit=20;
        table.init('tab', {
            cellMinWidth:120,
            skin: 'line,row',
            even: false,
            size: 'sm ',
            limit: limit
        });
    </script>
    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pages|raw|default=''}{/empty}
</div>
{/block}
